package com.example.config;

import com.example.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/user/email").excludePathPatterns("/user/login").excludePathPatterns("/user/phone").excludePathPatterns("/user/plogin").excludePathPatterns("/user/getToken").excludePathPatterns("/error").excludePathPatterns("/user/ulogin")
                .excludePathPatterns("/user/upimg").excludePathPatterns("/user/register").excludePathPatterns("/discuss/next").excludePathPatterns("/discuss/hot").excludePathPatterns("/answer/hot").excludePathPatterns("/discuss/getOne").excludePathPatterns("/web/**").excludePathPatterns("/discuss/comment").excludePathPatterns("/discuss/read")

                .excludePathPatterns("/discuss/new").excludePathPatterns("/discuss/getSize").excludePathPatterns("/comment/comments").excludePathPatterns("/comment/rcomment")

                .excludePathPatterns("/user/upimg").excludePathPatterns("/user/register").excludePathPatterns("/discuss/next").excludePathPatterns("/discuss/hot").excludePathPatterns("/answer/hot").excludePathPatterns("/discuss/getOne").excludePathPatterns("/discuss/new").excludePathPatterns("/discuss/getSize").excludePathPatterns("/comment/comments").excludePathPatterns("/user/not");
    }
}
